import actionType from '../actionTypes/user';
import type { UserInfoType } from '@/types/login';
const initialUserInfo: { userinfo: UserInfoType } = {
  userinfo: {
    username: '',
    sex: 'BOY',
    age: 0,
    headerImg: '',
    worker: '', // 职业
    address: '', //地址
    github: '',
    blogUrl: '', // 笔记地址
    tags: [],
  },
};
const userReducer = (
  state = initialUserInfo,
  action: UserInfoType & ActionType,
) => {
  switch (action.type) {
    case actionType.SETUSERINFO:
      return { userinfo: action };
    case actionType.REMOVEINFO:
      return { ...initialUserInfo };
    default:
      return state;
  }
};

export default userReducer;
